﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PickEmHats.UserControls
{
    public partial class EditTeams : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            PopulateTeams();
        }
        private void PopulateTeams()
        {
            TeamFactory factory = new TeamFactory(ConnectionStrings.Hats);
            gvEditTeams.DataSource = factory.GetTeamData();
            gvEditTeams.DataBind();
        }
       
        private void PopulateModalById(int teamId)
        {

        }

        public void SubmitTeam(Team t)
        {

        }

        protected void gvEditTeams_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Mod":
                    {
                        Button btnMod = (Button)Page.FindControl("ctl00$ContentPlaceHolder1$EditTeams$gvEditTeams$ctl02$btnModTeam");
                        Page.ClientScript.ValidateEvent(btnMod.UniqueID);
                        Page.ClientScript.RegisterStartupScript(
                            this.GetType(), "showTeamModal", "showTeamModal()");
                        PopulateModalById(Convert.ToInt32(e.CommandArgument));
                        break;
                    }
                default:
                    {
                        break;
                    }

            }
        }
    }
}